<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ include file="/WEB-INF/include/tag.jsp"%>
<%@ include file="/WEB-INF/include/common.jsp"%>

<link rel="stylesheet" href="${ctx}/statics/css/custom_theme.css" />
<style type="text/css">
.huozhui{
	position: relative;
	left:-25px
}
#model_edit_form td>label{
	width: 120px;
}

#model_edit_form input{
	width: 160px
}
#model_edit_form select{
	width: 160px
}
input,select{
	font-size: 14px;
}
.col-sm-3 button{
	padding: 0;
}
</style>
<div class="modal fade" id="modelRoleModel" tabindex="-1" role="dialog" aria-labelledby="modelRoleModelLabel" aria-hidden="true" data-backdrop="false">
    <div class="modal-dialog modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                	<span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="modelRoleModelLabel">${subTitle}</h4>
            </div>
            <div class="modal-body">
        		<div id="modelRoleModel_modal_body"></div>
            </div>
        </div>
    </div>
</div>
<!-- 模态窗口 -->
<div class="modal fade" id="modelModel" tabindex="-1" role="dialog" aria-labelledby="modelModelLabel" aria-hidden="true" data-backdrop="false">
  <div class="modal-dialog" style="width: 710px;">
        <div class="modal-content">
            <div class="modal-header">
            	<button type="button" class="close" data-dismiss="modal" aria-label="Close">
                	<span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" >添加车型</h4>
            </div>
            <div class="modal-body">
            	<form id="model_edit_form" class="form-horizontal" enctype="multipart/form-data">
			        <input type="hidden" name="id" id="model_id">
			        <table class="table table-condensed">
			        	<tr>
			        		<td><label>品牌名称</label></td>
			        		<td>
			        			<div class="group">
				        			<select name="brandId" id="edit_brandId" class="select_length">
						            	<option value="0">--请选择--</option>
						                  <c:forEach var="brand" items="${brandList}" varStatus="status" >
											<option value="${brand.id }">${brand.initial } ${brand.name }</option>
						                  </c:forEach>
									</select>
								</div>
			        		</td>
			        		<td><label>车系名称</label></td>
			        		<td>
				        		<div class="group">
				        			<select name="seriesId" id="edit_seriesId" class="select_length">
						            	<option value="0">--请选择--</option>
									</select>
								</div>
			        		</td>
			        	</tr>
			        	<tr>
			        		<td><label>车型名称</label></td>
			        		<td>
				        		<div class="group">
				        			<input name="name" id="name"/>
			        			</div>
			        		</td>
			        		<td><label>指导价</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="guidePrice" />
				        			<label class="huozhui">元</label>
			        			</div>
			        		</td>
			        	</tr>
			        	<tr>
			        		<td><label>车型级别</label></td>
			        		<td>
			        			<select name="levelName" id="edit_seriesId" class="select_length">
					            	<c:forEach var="brand" items="${che_jiegou}" varStatus="status" >
										<option value="${brand.itemName }">${brand.itemName }</option>
					                  </c:forEach>
								</select>
			        		</td>
			        		<td><label>进气类型</label></td>
			        		<td>
			        			<select name="flowModename" id="edit_seriesId" class="select_length">
					            	<c:forEach var="brand" items="${jin_qi}" varStatus="status" >
										<option value="${brand.itemName }">${brand.itemName }</option>
					                  </c:forEach>
								</select>
			        		</td>
			        	</tr>
			        	<tr>
			        		<td><label>驱动类型</label></td>
			        		<td>
			        			<select name="drivingModename" id="edit_seriesId" class="select_length">
					            	<c:forEach var="brand" items="${qu_dong}" varStatus="status" >
										<option value="${brand.itemName }">${brand.itemName }</option>
					                  </c:forEach>
								</select>
			        		</td>
			        		<td><label>变速箱类型</label></td>
			        		<td>
			        			<select name="transmissionType" id="edit_seriesId" class="select_length">
					            	<c:forEach var="brand" items="${bian_su}" varStatus="status" >
										<option value="${brand.itemName }">${brand.itemName }</option>
					                  </c:forEach>
								</select>
			        		</td>
			        		
			        	</tr>
			        	<tr>
			        		<td><label>排量</label></td>
			        		<td>
				        		<div class="group">
				        			<input name="displacement" />
				        			<label class="huozhui">L</label>
				        		</div>
			        		</td>
			        		<td><label>马力</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="horsepower" />
				        			<label class="huozhui">Ps</label>
				        		</div>
			        		</td>
			        		
			        	</tr>
			        	<tr>
			        		<td><label>最高车速</label></td>
			        		<td>
				        		<div class="group">
				        			<input name="maxSped" />
				        			<label class="huozhui" style="left:-39px">km/h</label>
				        		</div>
			        		</td>
			        		<td><label>油耗</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="oilConsumption" />
				        			<label class="huozhui">L</label>
				        		</div>
			        		</td>
			        	</tr>
			        	<tr>
			        		<td><label>变速箱档位数</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="gearboxNum" />
				        			<label class="huozhui">档</label>
				        		</div>
			        		</td>
			        		<td><label>发动机型号</label></td>
			        		<td>
			        			<input name="engineModename" />
			        		</td>
			        	</tr>
			        	<tr>
			        		<td><label>高度</label></td>
			        		<td>
			        			<div class="group">
			        				<input name="height"/>
				        			<label class="huozhui" style="left:-35px">mm</label>
				        		</div>
			        		</td>
			        		<td><label>长度</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="length" />
				        			<label class="huozhui" style="left:-35px">mm</label>
				        		</div>
			        		</td>
			        	</tr>
			        	<tr>
			        		<td><label>宽度</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="width" />
				        			<label class="huozhui" style="left:-35px">mm</label>
				        		</div>
			        		</td>
			        		<td><label>重量</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="weight" />
				        			<label class="huozhui" style="left:-30px">kg</label>
				        		</div>
			        		</td>
			        	</tr>
			        	<tr>
			        		<td><label>轴距</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="wheelBase" />
				        			<label class="huozhui" style="left:-35px">mm</label>
				        		</div>
			        		</td>
			        		<td><label>质保</label></td>
			        		<td>
			        			<input name="quality" />
			        		</td>
			        	</tr>
			        	<tr>
			        		<td><label>车门数量</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="strucDoor" />
				        			<label class="huozhui">个</label>
				        		</div>
			        		</td>
			        		<td><label>座位数</label></td>
			        		<td>
			        			<div class="group">
				        			<input name="trucSeat" />	
				        			<label class="huozhui">个</label>
				        		</div>
			        		</td>
			        	</tr>
			        </table>
			    </form>
            </div>
            <div class="modal-footer">
            	<button type="button" class="btn btn-sm btn-primary" id="modelModelBtn">确定</button>
                <button type="button" class="btn btn-sm btn-default" data-dismiss="modal" id="Close">关闭</button>
            </div>
        </div>
   </div>
</div>

<!--添加车型指导价模态窗  -->
<div class="modal fade" id="priceModel" tabindex="-1" role="dialog" aria-labelledby="modelModelLabel" aria-hidden="true" data-backdrop="false">
  <div class="modal-dialog" >
        <div class="modal-content" style="width:550px;">
            <div class="modal-header">
            	<button type="button" class="close" data-dismiss="modal" aria-label="Close">
                	<span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" >添加价格</h4>
            </div>
            <div class="modal-body">
            	<input type="hidden" name="model_id" id="modelId"> 
            	<form id="price_edit_form" class="form-horizontal" enctype="multipart/form-data">
            		<table class="table table-condensed" >
            			<tr>
            				<td><label>价格:</label></td>
            				<td><input type="text" name="price" id="price" class="form-control" style="width:330px;"/>
            				</td>
            			</tr>
            			<tr>
            				<td style="width: 85px"><label>选择省份：</label></td>
            				<td>
			            		<label><input name="address" type="checkbox" value="1"/>上海 </label> 
								<label><input name="address" type="checkbox" value="2" />北京 </label> 
								<label><input name="address" type="checkbox" value="3" />天津 </label> 
								<label><input name="address" type="checkbox" value="4" />河北</label> 
								<label><input name="address" type="checkbox" value="5" />江苏 </label> 
								<label><input name="address" type="checkbox" value="6" />浙江 </label> 
								<label><input name="address" type="checkbox" value="7" />重庆 </label> 
								<label><input name="address" type="checkbox" value="9" />辽宁 </label> 
								<label><input name="address" type="checkbox" value="10" />吉林 </label> 
								<label><input name="address" type="checkbox" value="12" />四川 </label> 
								<label><input name="address" type="checkbox" value="13" />安徽 </label> 
								<label><input name="address" type="checkbox" value="14" />福建 </label> 
								<label><input name="address" type="checkbox" value="15" />江西 </label> 
								<label><input name="address" type="checkbox" value="16" />山东 </label> 
								<label><input name="address" type="checkbox" value="17" />河南 </label> 
								<label><input name="address" type="checkbox" value="18" />湖北 </label> 
								<label><input name="address" type="checkbox" value="19" />湖南 </label> 
								<label><input name="address" type="checkbox" value="20" />广东 </label> 
								<label><input name="address" type="checkbox" value="21" />广西 </label> 
								<label><input name="address" type="checkbox" value="22" />海南 </label> 
								<label><input name="address" type="checkbox" value="23" />贵州 </label> 
								<label><input name="address" type="checkbox" value="24" />云南 </label> 
								<label><input name="address" type="checkbox" value="25" />西藏 </label> 
								<label><input name="address" type="checkbox" value="26" />陕西 </label> 
								<label><input name="address" type="checkbox" value="27" />甘肃 </label> 
								<label><input name="address" type="checkbox" value="28" />青海 </label> 
								<label><input name="address" type="checkbox" value="29" />新疆 </label> 
								<label><input name="address" type="checkbox" value="30" />宁夏 </label> 
								<label><input name="address" type="checkbox" value="31" />台湾 </label> 
								<label><input name="address" type="checkbox" value="32" />山西 </label>
								<label><input name="address" type="checkbox" value="8" />内蒙古</label>
								<label><input name="address" type="checkbox" value="11" />黑龙江 </label>
							</td>
						</tr>
						<tr>
							<td align="center" colspan="2"><label><input type="checkbox" id="all"> 全选/全不选</label></td>
						</tr>	
		            </table>
            	</form>
            </div>
            <div class="modal-footer">
            	<button type="button" class="btn btn-sm btn-primary" onClick="addPrice()">确定</button>
                <button type="button" class="btn btn-sm btn-default" data-dismiss="modal" id="Close">关闭</button>
		     </div>
        </div>
   </div>
</div>

<div id="main-content">
	<div class="panel panel-default">
		<div class="panel-heading">${title}</div>
		<!-- /.panel-heading -->
		<div class="panel-body" >
			<!-- PAGE CONTENT BEGINS -->
			<form class="form-horizontal" role="form" id="model_search_form">
				<div class="col-sm-9">
					<label class="control-label col-sm-1">品牌</label>
		        	<div class="col-sm-2">
			            <select name="brandId" id="search_brandId" style="width: 100px">
			            	<option value="0">--请选择--</option>
			                  <c:forEach var="brand" items="${brandList}" varStatus="status" >
								<option value="${brand.id }">${brand.initial } ${brand.name }</option>
			                  </c:forEach>
						</select>
		        	</div>
		        	<label class="control-label col-sm-1">车系</label>
		        	<div class="col-sm-2">
			            <select name="seriesId" id="search_seriesId" style="width: 100px">
			            	<option value="0">--请选择--</option>
						</select>
		        	</div>
		        	<label class="control-label col-sm-1">名称</label>
		        	<div class="col-sm-2">
			            <input type="text" name="name" style="width:120px;">
		        	</div>
					<label class="control-label col-sm-1">状态 </label>
					<div class="col-sm-2">
						<select	name="isDelete" id="search_status">
							<option value="false">未删除</option>
							<option value="true">已删除</option>
						</select>
					</div>
				</div>
				<div class="col-sm-3" style="margin:0;">
					<button class="btn btn-sm btn-info" type="submit">
						<i class="icon-search nav-search-icon"></i>查询
					</button> 
					<button type="button" class="btn btn-success btn-sm" onclick="addData()"><i class="icon-plus bigger-110"></i>添加</button>
					<button class="btn btn-sm btn-primary" type="reset"	>
						<i class="icon-undo bigger-110"></i>清除
					</button> 
					<button type="button" class="btn btn-success btn-sm" onclick="exportCar()"><i class="icon-plus bigger-110"></i>导出数据</button>
				</div>
			</form>
			<div id="model_table_tools">
				<div class="text-right">
				</div>
			</div>
			<table id="model_table" class="table table-bordered table-hover table-condensed">
			</table>
		</div>
	</div>
</div>

<script type="text/javascript">
$(function(){
	$('#model_table').bootstrapTable({
		url: '${ctx}/business/car/getModelList.do',
		classes :"table-condensed",
		pagination: true,
		paginationLoop: false,
		smartDisplay: false,
		striped: true,
	    pageSize: 10,
	    pageList: [10, 20, 50, 100],
	    sidePagination: 'server',
	    showRefresh: false,
	    showColumns: false,
	    detailView:true,
	    paginationNextText:'下一页',
	    paginationPreText:'上一页',
	    cache: false,
	    onExpandRow: function (index,row, $detail) {
	    	detailHtml(row,$detail);
		},
		columns: [{
			field: '',
			title: '操作',
			align: 'center',
			width:'120px',
			formatter: function(value, row, index){
				if(row.isDelete==true){
					return '<button class="btn btn-xs btn-info" id="bacckData" title="还原"><i class="icon-reply bigger-130"></i></button>'
					+'<button class="btn btn-xs btn-danger" id="deleteReaData" title="删除"><i class="icon-trash bigger-130"></i></button>';
				}else{
					return '<button class="btn btn-xs btn-success" id="editPrice" title="添加价格"><i class="glyphicon glyphicon-usd bigger-130"></i></button>'
							+'<button class="btn btn-xs btn-info" id="editData" title="编辑"><i class="glyphicon glyphicon-edit bigger-130"></i></button>'
							+'<button class="btn btn-xs btn-danger" id="deleteData" title="删除"><i class="glyphicon glyphicon-trash bigger-130"></i></button>';
				}
			},
			events: {
				'click #editPrice': editPrice,
				'click #editData': editData,
				'click #deleteData': deleteData,
				'click #bacckData': bacckData,
				'click #deleteReaData': deleteReaData
			}
		},{
			field: 'id',
			title: 'ID',
			align:"center"
		},{
			field: 'brandName',
			title: '品牌',
			align:"center"
		},{
			field: 'seriesName',
			title: '车系',
			align:"center"
		},{
			field: 'name',
			title: '名称',
			align:"center"
		},{
			field: 'guidePrice',
			title: '指导价',
			align:"center"
		},{
			field: 'creatime',
			title: '创建时间',
			align:"center"
		},{
			field: 'isDelete',
			title: '状态',
			align:"center",
			formatter: function(val, row, index){
				var str='-';
				if(val){
					str = '<span style="color:red">已删除</span>';
				}else{
					str ='<span style="color:green">未删除</span>';
				}
				return str;
			}
		}],
		queryParams: function(params){
			//console.log(params);
			//params.usreId
			$.extend(params,$("#model_search_form").serializeJson());
			return params;
		}
		
		
	});

	$('#model_table').on('mouseenter','.pannel_a_title',function () {
        $(this).popover('show');
	});
	// 新规则要求值必须与第一个参数相同
	$.validator.addMethod("unequal",function(value,element,param){  
		return this.optional( element ) || value != param;
	},"请选择");
	$.extend($.validator.messages, {
		digits: "只能输入整数"
	});
	//添加和编辑请求验证
	 $("#model_edit_form").validate({
		 errorPlacement: function(error, element) {
				// Append error within linked label
			 error.appendTo(element.parent("div").after("<label></label>").next("label"));
			},
			rules: {
				brandId : {unequal : 0},
				seriesId : {unequal : 0},
				name : {
					required : true,
					remote: {
					    url: "${ctx}/business/car/checkedModelName.do",     //后台处理程序
					    type: "post",               //数据发送方式
					    dataType: "json",         //接受数据格式   
					    data:{
					    	id: function() {
					            return $("#model_id").val();
					        },
					        seriesId: function() {
					            return $("#edit_seriesId").val();
					        }
					    }
					}
				},
				enName : {required : true},
				guidePrice : {required : true,number : true,min : 0},
				displacement : {number : true,min : 0},
				horsepower : {number : true,min : 0},
				maxSped : {number : true,min : 0},
				oilConsumption : {number : true,min : 0},
				gearboxNum : {number : true,min : 0,digits:true},
				height : {number : true,min : 0,digits:true},
				width : {number : true,min : 0,digits:true},
				weight : {number : true,min : 0,digits:true},
				length : {number : true,min : 0,digits:true},
				wheelBase : {number : true,min : 0,digits:true},
				strucDoor : {number : true,min : 0,digits:true},
				trucSeat : {number : true,min : 0,digits:true}
			},
			messages: {
			     name:{remote:"该车型名称已经被添加"},
			    },
			submitHandler : function(form) {
				$("#modelModel").prop("disabled", true);
				
				$(form).ajaxSubmit({
					type : "post",
					dataType : "json",
					url : "${ctx}/business/car/saveOrUpdateModel.do",
					success : function(data) {
						if (data.success == true) {
							$('#modelModel').modal('hide');
							$('#model_table').bootstrapTable('refresh');
						} else {
							alert(data.errorMessage);
						}
						$("#modelModel").prop("disabled", false);
					}
				});
			}
		});

		//提交信息
		$("#modelModel").on('click', '#modelModelBtn', function() {
			$("#model_edit_form").submit();
		});
		//搜索角色
		$("#model_search_form").submit(function(e) {
			e.preventDefault();
			$('#model_table').bootstrapTable('refresh');
		});

		$("#search_brandId").change(function() {
			changeSeries($(this).val(), "search_seriesId");
		});
		$("#edit_brandId").change(function() {
			changeSeries($(this).val(), "edit_seriesId");
		});
		$("#edit_seriesId").change(function() {
			$("#name").removeData("previousValue"); 
		});
		//添加价格
		 $("#price_edit_form").validate({
				rules: {
					price : {required:true,number : true,min : 0}
				},
				submitHandler : function(form) {
					var model_id=$("#modelId").val();//获得车型id
					//alert(model_id);
					var arr=document.getElementsByName("address");//获得省份(id)
					var a=new Array();;
					for(var i=0;i<arr.length;i++){
						if(arr[i].checked){
							var b={
								"id":i,
								"address":arr[i].value
							};
							a.push(b);
						}
					}
					var address=JSON.stringify(a) //把地址数组转换成JSON
					var price=$("#price").val();//获得价格
						$.ajax({
							url : "${ctx}/business/car/addPrice.do",
							type : "POST",
							data : {
								"carModelId" : model_id,
								"address" : address,
								"price" : price
							},
							success : function(data) {
								if (data.success) {
									$('#priceModel').modal('hide');
									$('#model_table').bootstrapTable('refresh');
								} else {
									alert(data.errorMessage);
								}
							}
						});
				}
			});

			//提交信息
			$("#price_edit_form").on('click', '#modelModelBtn', function() {
				$("#model_edit_form").submit();
			});

	});

	function changeSeries(value, id) {
		var brandId = value;
		$.ajax({
			url : "${ctx}/business/car/getSeriesListByBrandId.do",
			type : "POST",
			data : {
				"brandId" : brandId
			},
			success : function(data) {
				var html = '<option value="0">--请选择--</option>';
				var list = data.rows;
				list.forEach(function(val, index, arr) {
					html += '<option value="'+val.id+'">' + val.name
							+ '</option>';
				});
				$("#" + id).html(html);

			}
		});
	}

	//添加价格
	function editPrice(e, v, row){
		$("#priceModel .modal-title").empty().html("添加价格");
		$("#price_edit_form").resetForm();
		//$("#price_edit_form input[name=model_id]").val(row.id);
		$("#modelId").val(row.id);
		$('#priceModel').modal('show');
	}
	
	//全选/全不选
	$("#all").click(function(){
		$("[name=address]:checkbox").prop("checked",this.checked);
		});
		$("[name=address]:checkbox").click(function(){
		var flag=true;
		$("[name=address]:checkbox").each(function(){
		if(!this.checked){
		flag=false;
		}
	});
	$("#all").prop("checked",flag);
	})
	
	function addPrice(){
			
		$("#price_edit_form").submit();
			
	}
	function addData(e, v, row) {
		$("#model_edit_form").validate().resetForm();
		$("#modelModel .modal-title").empty().html("添加车型");
		
		$("#model_edit_form select[name=seriesId]").html('<option value="0">--请选择--</option>');
		$("#model_edit_form input[name=id]").val("");
		$("#model_edit_form input[name=name]").val("");
		$("#model_edit_form input[name=enName]").val("");
		$("#model_edit_form input[name=initial]").val("");
		$("#model_edit_form input[name=remark]").val("");
		$('#modelModel').modal('show');
	}
	function exportCar(e, v, row) {
		window.location.href="${ctx}/business/car/exportCar.do"
	}

	//编辑用户
	function editData(e, v, row) {
		$("#modelModel .modal-title").empty().html("编辑车型");
		$("#model_edit_form").validate().resetForm();
		$("#model_edit_form input[name=id]").val(row.id);
		$("#model_edit_form select[name=brandId]").val(row.brandId);
		$("#model_edit_form select[name=seriesId]").html('<option value="'+row.seriesId+'">' + row.seriesName+ '</option>');
		$("#model_edit_form input[name=name]").val(row.name);
		$("#model_edit_form input[name=guidePrice]").val(row.guidePrice);
		$("#model_edit_form select[name=levelName]").val(row.levelName);
		$("#model_edit_form input[name=engineModename]").val(row.engineModename);
		$("#model_edit_form input[name=displacement]").val(row.displacement);
		$("#model_edit_form input[name=horsepower]").val(row.horsepower);
		$("#model_edit_form select[name=flowModename]").val(row.flowModename);
		$("#model_edit_form select[name=drivingModename]").val(row.drivingModename);
		$("#model_edit_form input[name=maxSped]").val(row.maxSped);
		$("#model_edit_form input[name=oilConsumption]").val(row.oilConsumption);
		$("#model_edit_form input[name=gearboxNum]").val(row.gearboxNum);
		$("#model_edit_form select[name=transmissionType]").val(row.transmissionType);
		$("#model_edit_form input[name=height]").val(row.height);
		$("#model_edit_form input[name=length]").val(row.length);
		$("#model_edit_form input[name=width]").val(row.width);
		$("#model_edit_form input[name=weight]").val(row.weight);
		$("#model_edit_form input[name=wheelBase]").val(row.wheelBase);
		$("#model_edit_form input[name=quality]").val(row.quality);
		$("#model_edit_form input[name=strucDoor]").val(row.strucDoor);
		$("#model_edit_form input[name=trucSeat]").val(row.trucSeat);
		$('#modelModel').modal('show');
	}

	//删除用户
	function deleteData(e, v, row) {
		var r = confirm("你确定删除“" + row.name + "”吗？");
		if (r) {
			$.ajax({
				url : "${ctx}/business/car/deleteById.do",
				type : "POST",
				data : {
					"id" : row.id,
					"type" : "model"
				},
				success : function(data) {
					if (data.success) {
						$('#model_table').bootstrapTable('refresh');
					} else {
						alert(data.errorMessage);
					}
				}
			});
		}
	}
	
	function detailHtml(row,$detaile){
		var html = '';
		html+='<table class="table"><tr><th>省份</th><th>价格</th></tr>';
		$.ajax({
			url : "${ctx}/business/car/queryPriceByModelId.do",
			type : "POST",
			async: false,//设置为同步
			data : {
				"carModelId" : row.id
			},
			success : function(data) {
				if((data.rows)!=null && (data.rows).length>0){
					for(var i=0;i<(data.rows).length;i++){
						html+='<tr id="'+data.rows[i].id+'"><td>'+data.rows[i].provinceName+'</td><td>'+data.rows[i].price+'</td><td><button class="btn btn-xs btn-danger" onclick="deleteprice('+data.rows[i].id+')" title="删除"><i class="glyphicon glyphicon-trash bigger-130"></i></button></td></tr>';
					}
				}
			}
		});
		html+='</table>';
		if(row.levelName!=null){
			html+='<p><span style="font-size:14px"><strong>车型级别：</strong>'+row.levelName+'</span></p>';
		}
		if(row.engineModename!=null){
			html+='<p><span style="font-size:14px"><strong>发动机型号：</strong>'+row.engineModename+'</span></p>';
		}
		if(row.displacement!=null){
			html+='<p><span style="font-size:14px"><strong>排量：</strong>'+row.displacement+'</span></p>';
		}
		if(row.horsepower!=null){
			html+='<p><span style="font-size:14px"><strong>马力：</strong>'+row.horsepower+'</span></p>';
		}
		if(row.flowModename!=null){
			html+='<p><span style="font-size:14px"><strong>进气类型：</strong>'+row.flowModename+'</span></p>';
		}
		if(row.drivingModename!=null){
			html+='<p><span style="font-size:14px"><strong>驱动类型：</strong>'+row.drivingModename+'</span></p>';
		}
		if(row.maxSped!=null){
			html+='<p><span style="font-size:14px"><strong>最高车速：</strong>'+row.maxSped+'</span></p>';
		}
		if(row.oilConsumption!=null){
			html+='<p><span style="font-size:14px"><strong>油耗：</strong>'+row.oilConsumption+'</span></p>';
		}
		if(row.gearboxNum!=null){
			html+='<p><span style="font-size:14px"><strong>变速箱档位数：</strong>'+row.gearboxNum+'</span></p>';
		}
		if(row.transmissionType!=null){
			html+='<p><span style="font-size:14px"><strong>变速箱类型：</strong>'+row.transmissionType+'</span></p>';
		}
		if(row.height!=null){
			html+='<p><span style="font-size:14px"><strong>高度：</strong>'+row.height+'</span></p>';
		}
		if(row.length!=null){
			html+='<p><span style="font-size:14px"><strong>长度：</strong>'+row.length+'</span></p>';
		}
		if(row.width!=null){
			html+='<p><span style="font-size:14px"><strong>宽度：</strong>'+row.width+'</span></p>';
		}
		if(row.weight!=null){
			html+='<p><span style="font-size:14px"><strong>重量：</strong>'+row.weight+'</span></p>';
		}
		if(row.wheelBase!=null){
			html+='<p><span style="font-size:14px"><strong>轴距：</strong>'+row.wheelBase+'</span></p>';
		}
		if(row.quality!=null){
			html+='<p><span style="font-size:14px"><strong>质保：</strong>'+row.quality+'</span></p>';
		}
		if(row.strucDoor!=null){
			html+='<p><span style="font-size:14px"><strong>车门数量：</strong>'+row.strucDoor+'</span></p>';
		}
		if(row.trucSeat!=null){
			html+='<p><span style="font-size:14px"><strong>座位数：</strong>'+row.trucSeat+'</span></p>';
		}
				  
		$detaile.html(html);
				  
	}
	//恢复
	function bacckData(e,v,row){
		var r = confirm("你确定还原“" + row.name + "”吗？");
		if (r) {
			$.ajax({
				url : "${ctx}/business/car/backById.do",
				type : "POST",
				data : {
					"id" : row.id
				},
				success : function(data) {
					if (data.success) {
						$('#model_table').bootstrapTable('refresh');
					} else {
						alert(data.errorMessage);
					}
				}
			});
		}
	}
	//删除
	function deleteReaData(e,v,row){
		var r = confirm("你确定删除“" + row.name + "”吗？");
		if (r) {
			$.ajax({
				url : "${ctx}/business/car/deleteReaData.do",
				type : "POST",
				data : {
					"id" : row.id
				},
				success : function(data) {
					if (data.success) {
						$('#model_table').bootstrapTable('refresh');
					} else {
						alert(data.errorMessage);
					}
				}
			});
		}
	}
	
	function deleteprice(id){
			$.ajax({
				url : "${ctx}/business/car/deletePrice.do",
				type : "POST",
				data : {
					"id" : id
				},
				success : function(data) {
					if (data.success) {
						$("#"+id).remove();
					} else {
						alert(data.errorMessage);
					}
				}
			});
		
	}
			  
</script>